﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DotNet.Business;
using DotNet.Model;
using DotNet.Common;
public partial class Admin_addHotQuestion : System.Web.UI.Page
{

    hotQuestionBll hqBll = new hotQuestionBll();
    protected void Page_Load(object sender, EventArgs e)
     {
        if (!IsPostBack)
        {
             if (Request.QueryString["action"]!=null)
            {
                 string action = Request.QueryString["action"];
                switch (action.Trim())
                {                   
                    case "submit":
                        Insert();
                        break;                                     
                    case "edit":
                        edit();
                        break;
                    default:
                    break;
                }                
            }
        }
    }
    #region 编辑
    public void edit()
    {
        int id = Convert.ToInt32(Request.QueryString["hqid"]);
        hotQuestion hq = hqBll.GetModel(id);
        this.hqTitle.Value = hq.hotQuestionTitle;
        this.FCKeditor1.Value = hq.hotQuestionDescription;
        this.hqid_hid.Value ="&hqId="+id.ToString();
    }
    #endregion

    #region 添加
    public void Insert()
    {
        hotQuestion hq = new hotQuestion();
        hq.hotQuestionTitle = Request.Form["hqTitle"].ToString();
        hq.hotQuestionDescription =Server.HtmlDecode(Request.Form["FCKeditor1"].ToString());
        if (hq.hotQuestionDescription.Trim()=="")
        {
            Response.Write("2");
            Response.End();
        }
        if (Request.QueryString["hqId"]!=null)
        {
            hq.hotQuestionID = Convert.ToInt32(Request.QueryString["hqId"]);
        }
        if (hq.hotQuestionID > 0)
        {
            if (hqBll.Update(hq))
            {
                Response.Write("保存成功！");
                Response.End();
            }
        }
        else 
        {
            if (hqBll.Insert(hq))
            {
                Response.Write("添加成功！");
                Response.End();
            }
        }
       
    }
    #endregion
}
